package com.burgeon.backend.Rest.Tool;
/**
 * 获取默认卡类型
 */


import com.burgeon.backend.Rest.base.RESTBase;
import org.json.JSONArray;
import org.springframework.util.MultiValueMap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class GetVIPTypeDefault extends RESTBase {

    private String ip;
    private String account;
    private String password;

    public GetVIPTypeDefault(String ip, String account, String password) {
        this.ip = ip;
        this.account = account;
        this.password = password;
    }

    /**
     * 发送并接收字符创
     */

    public String getData() throws Exception {
        String url = "http://"+ip+"/servlets/binserv/Rest";

        String str = RESULT(Data(),url);

        JSONArray jsonArray = new JSONArray(str).getJSONObject(0).getJSONArray("rows");
        str = jsonArray.getJSONArray(0).getString(0);
        return str;
    }

    private MultiValueMap Data( ) {
        HashMap params = new HashMap();
        ArrayList columns = new ArrayList();//查询字段
        columns.add("NAME");


        params.put("columns", columns);
        params.put("table", "C_VIPTYPE");//表名

        HashMap orderby = new HashMap();


        orderby.put("column","ID");
        orderby.put("asc","true");
        ArrayList list = new ArrayList();
        list.add(orderby);

        params.put("orderby",list);
        params.put("range","1");

        return DATA("Query", params,account,password);
    }

    public static void main(String[] args) {
        GetVIPTypeDefault g = new GetVIPTypeDefault("39.104.52.2:55321","nea@burgeon.com.cn","rs55321");
        try {
            System.err.println(g.getData());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
